package pe.edu.pucp.cpnc.mm.bean;

import java.io.Serializable;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;

public abstract  class  Object implements Serializable{
    protected int id;
    protected String name;
    @XmlElementWrapper
    @XmlElement(name ="pad")
    protected int padding[];
    protected int type;
    protected int path; //0 = water; 1 = land
    protected int sizeX; //Cuanto ocupa en X
    protected int sizeY; // Cuanto ocupa en Y
    protected ArrayList<String> sprite;
    
    public enum PadCode{
        TOP(0),BOT(1),RIGHT(2),LEFT(3);
        public final int code;
        PadCode(int code){
            this.code = code;
        }
    }
	
    public Object(){
        sprite = null;
    }
    
    public Object(int id, String name, int type, int path, int sizeX, int sizeY, ArrayList<String> sprite){
    	this.id = id;
    	this.name = name;
    	this.type = type;
    	this.path = path;
    	this.sizeX = sizeX;
    	this.sizeY = sizeY;
    	this.sprite = sprite;
    }
		
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public int getPath() {
		return path;
	}
	public void setPath(int path) {
		this.path = path;
	}
	public int getSizeX() {
		return sizeX;
	}
	public void setSizeX(int sizeX) {
		this.sizeX = sizeX;
	}
	public int getSizeY() {
		return sizeY;
	}
	public void setSizeY(int sizeY) {
		this.sizeY = sizeY;
	}
        
        public int getPadding(PadCode pc){
            return padding[pc.code];
        }
        
        public void setPadding(PadCode pc, int pad){
            padding[pc.code] = pad;
        }
        
        @XmlElementWrapper
	@XmlElement(name ="String")
	public ArrayList<String> getSprite() {
		return sprite;
	}
        
        public String getSpriteToRender(int orientation){
            try{
                return sprite.get(orientation);
            }catch(IndexOutOfBoundsException ex){
                if(!sprite.isEmpty())
                    return sprite.get(0);
                else return "";
            }
        }
        
	public void setSprite(ArrayList<String> sprite) {
		this.sprite = sprite;
	}
	
	public int add(int posX, int posY, Object object, Map map, int idPlayer, int orientation){		
		return 0;		
	}
	
	public int add(int posX, int posY, Object object, Map map, int idPlayer){
		return 0;
		
	}
	
	public int add(int posX, int posY, Object object, Map map){
		return 0;
		
	}	
	
        @Override
        public String toString(){
            return name;
        }
		

}
